/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model.entity;

import com.alibaba.fastjson.annotation.JSONField;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author dingnangen
 */
@Entity
@Table(name = "attendance")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Attendance.findAll", query = "SELECT a FROM Attendance a"),
    @NamedQuery(name = "Attendance.findByIdattendance", query = "SELECT a FROM Attendance a WHERE a.idattendance = :idattendance"),
    @NamedQuery(name = "Attendance.findByAttendancedate", query = "SELECT a FROM Attendance a WHERE a.attendancedate = :attendancedate")})
public class Attendance implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idattendance")
    private Integer idattendance;
    @Column(name = "attendancedate")
    @Temporal(TemporalType.DATE)
    private Date attendancedate;
    @JSONField(label = "extask")
    @JoinTable(name = "problem_attendance", joinColumns = {
        @JoinColumn(name = "idattendance", referencedColumnName = "idattendance")}, inverseJoinColumns = {
        @JoinColumn(name = "idproblem", referencedColumnName = "idproblem")})
    @ManyToMany
    private List<Problem> problemList;
    @JSONField(label = "extask")
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idattendance")
    private List<Task> taskList;
    @JoinColumn(name = "iddepot", referencedColumnName = "iddepot")
    @ManyToOne
    private Depot iddepot;
    @JoinColumn(name = "iddriver", referencedColumnName = "iddriver")
    @JSONField(label = "extask")
    @ManyToOne
    private Driver iddriver;
    @JoinColumn(name = "idvehicle", referencedColumnName = "idvehicle")
    @ManyToOne
    private Vehicle idvehicle;

    public Attendance() {
    }

    public Attendance(Integer idattendance) {
        this.idattendance = idattendance;
    }

    public Integer getIdattendance() {
        return idattendance;
    }

    public void setIdattendance(Integer idattendance) {
        this.idattendance = idattendance;
    }

    public Date getAttendancedate() {
        return attendancedate;
    }

    public void setAttendancedate(Date attendancedate) {
        this.attendancedate = attendancedate;
    }

    @XmlTransient
    public List<Problem> getProblemList() {
        return problemList;
    }

    public void setProblemList(List<Problem> problemList) {
        this.problemList = problemList;
    }

    @XmlTransient
    public List<Task> getTaskList() {
        return taskList;
    }

    public void setTaskList(List<Task> taskList) {
        this.taskList = taskList;
    }

    public Depot getIddepot() {
        return iddepot;
    }

    public void setIddepot(Depot iddepot) {
        this.iddepot = iddepot;
    }

    public Driver getIddriver() {
        return iddriver;
    }

    public void setIddriver(Driver iddriver) {
        this.iddriver = iddriver;
    }

    public Vehicle getIdvehicle() {
        return idvehicle;
    }

    public void setIdvehicle(Vehicle idvehicle) {
        this.idvehicle = idvehicle;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idattendance != null ? idattendance.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Attendance)) {
            return false;
        }
        Attendance other = (Attendance) object;
        if ((this.idattendance == null && other.idattendance != null) || (this.idattendance != null && !this.idattendance.equals(other.idattendance))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.entity.Attendance[ idattendance=" + idattendance + " ]";
    }
    
}
